<template>
	<view class="container">
		<view class="per-man-List">
			<view class="per-man-item" v-for="(item,index) in perList" :key='index'>
				<text>{{item.name}}</text>
				<view class="per-man-itemImg" @click="operation(1,item.id)">
					<image src="../../static/ic_write.png" mode="widthFix"></image>
				</view>
			</view>
		</view>
		<view class="per-man-add">
			<view class="per-man-addNav" @click="operation(0,null)">
				<view class="per-man-addImg">
					<image src="../../static/icon_plus.png" mode="widthFix"></image>
				</view>
				<text class="per-man-addText">新增就诊人</text>
			</view>
		</view>
	</view>
</template>

<script>
	import app from '../../App.vue'
	export default {
		data() {
			return {
				perList: [],
			}
		},
		onShow() {
			this.getperList()
		},
		methods: {
			getperList() {
				let that = this
				app.post('api/user_member/getUserMemberList',{}).then(res => {
					if (res.code == 1) {
						that.perList = res.data
					} else if (res.code == 401) {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							mask: true
						})
					}
				})
			},
			operation(status,id){
				console.log(id)
				if(id == null){
					uni.showLoading({
						title:'加载中',
						success() {
							setTimeout(function(){
								uni.hideLoading({
									success(){
										uni.navigateTo({
											url:'/pages/yuyue/addPatient?status='+status
										})
									}
								})
							},1300)
						}
					})
				}else{
					uni.showLoading({
						title:'加载中',
						success() {
							setTimeout(function(){
								uni.hideLoading({
									success(){
										uni.navigateTo({
											url:'/pages/yuyue/addPatient?status='+status+'&id='+id
										})
									}
								})
							},1300)
						}
					})
				}
			},
		}
	}
</script>

<style>
	@import url("../../common/permanage.css");
</style>
